package stackqueuelinkedlist;

public class ReverseLinkedList {
	public static class Node{
		int element;
		Node next;
		
		public Node(int i){
			element = i;
		}
	}
	
	public static void reverseList (Node start) {
	     Node currentNode = start;
	     Node prevNode = null;
	      while (currentNode !=null) {
	           // save value of next Node
	           Node nextNode = currentNode.next;

	           // change link
	           currentNode.next = prevNode;

	            // List traverse
	            prevNode = currentNode;
	            currentNode = nextNode;;
	     }
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Node n = new Node(1);
		n.next = new Node(2);
		n.next.next = new Node(3);
		reverseList(n);
	}

}
